package eu.supersheep.dao;

import java.util.Dictionary;

import android.util.Log;
import eu.supersheep.dao.Response;

public class DAO {
	private static final DAO sharedInstance = new DAO();
	
	private DAO() {
	}
	
    public static DAO getInstance() {
        return sharedInstance;
    }
    
    // TODO: jesli w json jest wiecej parametrow to sie wypieprza 
    
    /**
     * Metoda zwraca odpowiedz od serwera
     * @param responseName - nazwa modulu
     * @param serviceName - nazwa uslugi
     * @param params - parametry post uslugi
     * @return Response
     */
    public Response getResponse (String moduleName,String serviceName,Dictionary<String, String> params,String responseName) {
    	JsonUtils jsonUtils = JsonUtils.getInstance();
    	HttpClient httpClient = HttpClient.getInstance();
    	String url = "http://supersheep.eu/"+moduleName+"/"+serviceName;
    	String json = httpClient.get(url);
    	Response response = jsonUtils.prepare(json, responseName);
    	return response;
    }
}
